public class test {

    public static <T> void swap(T[] array, int i, int j){
        T temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }
    public static void main(String[] args) {
        String[] strings = new String[]{"abc","def"};
        Integer[] ints = new Integer[]{1,2};
        swap(strings,0,1);
        swap(ints,0,1);
        System.out.println(strings[0]);
        System.out.println(strings[1]);
        System.out.println(ints[0]);
        System.out.println(ints[1]);
    }
}
